﻿using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SDPChecker;

namespace SPDChecker.Tests
{
    [TestClass]
    public class DependenciesParserTests
    {
            private List<AssemblyInfo> _assemblies;

            private readonly string[] _assemblyNames = {  "MyProject.Domain", 
                                                "MyProject.Service.DataContracts", 
                                                "MyProject.CalculationService.Data"};

        [TestInitializeAttribute]
        public void Initialize()
        {
            _assemblies = new DependenciesParser(new StringReader(Resources.AssembliesDependencies)).GetDependencies(_assemblyNames).ToList();
        }

        [TestMethodAttribute]
        public void TestDependencies()
        {
            Assert.AreEqual(_assemblyNames.Count(), _assemblies.Count, "Number of dependencies");
            Assert.AreEqual("MyProject.Domain", _assemblies[0].Name, "First assembly is not named right");
            Assert.AreEqual(4, _assemblies[0].Dependencies.Count(), "Number of dependencies");
            Assert.AreEqual("MyProject.Domain", _assemblies[1].Dependencies.ToList()[3].Name, "First assembly is not named right");
        }        
    }
}
